<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="viewport" content="user-scalable=no, initial-scale=1,
       maximum-scale=1, minimum-scale=1, width=device-width">
  <title>电子书选阅</title>
  <!--suppress HtmlUnknownTarget -->
  <link rel="stylesheet" href="./css/zTreeStyle.css" type="text/css">
  <!--suppress HtmlUnknownTarget -->
  <script type="text/javascript" src="./js/jquery-3.3.1.min.js"></script>
  <!--suppress HtmlUnknownTarget -->
  <script type="text/javascript" src="./js/jquery.ztree.core.js"></script>
  <!--suppress HtmlUnknownTarget -->
  <script type="text/javascript" src="./js/cloud.js"></script>
  <!--suppress CssUnknownTarget, HtmlUnknownTarget -->
  <script src="./js/jszip.min.js"></script>
  <!--suppress HtmlUnknownTarget -->
  <script src="./js/epub.js"></script>
  <!--suppress CssUnknownTarget -->
  <style>
    html, body { height: 98%; }
    .flexbox{ display: flex; align-items: center; justify-content: center;}
    .btnStl { border-radius: 6px; background-color: #EED5D2; color: blue; }
    .bgFrame { background-color:#1c77ac; background-image:url(./img/light.png);
      background-repeat:no-repeat; background-position:center top; overflow:hidden; }
    #mainBody {width:100%;height:100%;position:absolute;z-index:-1;}
    .cloud {position:absolute;top:0;left:0;width:100%;height:100%;
      background:url(./img/cloud.png) no-repeat;z-index:1;opacity:0.5;}
    #cloud2 {z-index:2;}
    .aceEdt { margin-top: 5px; background:transparent; /*overflow-x: hidden;*/}
    .left  { margin-top: 2px; width: 25%; text-align:left; color: blue}
    .right { width: 65%;}
    .ztree { border: 1px solid white; background: transparent;
      overflow-y: auto; overflow-x:auto;}
  </style>
  <script>
  </script>
</head>
<body class="bgFrame" onload="" onunload="">
  <div id="mainBody" >
    <div id="cloud1" class="cloud"></div>
    <div id="cloud2" class="cloud"></div>
  </div>
  <h2 class="flexbox" style="color: orange;">徐国洋电子书选阅</h2>
  <div style="height: 90%; text-align:center; margin: 7px; border: 2px solid orange;" id="zone">
    <div class="flexbox">
      <div class="left" id="drctZone">
        <ul class="ztree" id="treeZone"></ul>
        <div class="flexbox">
          <input type="button" class="btnStl" value="徐国洋电子书选阅" onclick="sysShow();" title="进入选定书目浏览页面"/>
        </div>
      </div>
      <div class="right" id="orgFl">
        <div class="aceEdt" id="fileZone"></div>
      </div>
    </div>
  </div>
  <div class="flexbox" style="font-size: 15px; height: 5%; color: #cde6c7" title=" ">
    <!--suppress HtmlUnknownTarget -->
    <img alt="" src="./img/dragon.png"/>
    <a style="color: #feeeed" href="http://101.200.15.192:9605/drctXpl" target="outFrame">徐国洋&nbsp&nbsp</a>
    <a style="color: #d5c59f" href="http://www.beian.miit.gov.cn" target="outFrame">赣ICP备15004836号-6&nbsp&nbsp</a>
      &nbsp&nbsp赣公网安备36012302000056号
    <!--suppress HtmlUnknownTarget -->
    <img alt="" src="./img/sft.png"/>
  </div>
</body>
<script>
  let bookNm = "", book, rendition
  function dnmHeight() {                       // 动态高度[响应布局]
    let u = $("#zone"), v = $("#fileZone"), w = $("#treeZone")
    let a = u.height(), b = u.width()
    a *= 0.99; let c = b * 0.65, d = b * 0.25; b = a * 0.93
    v.height(a); v.width(c)
    w.height(b); w.width(d)
  }
  function epubLdShow() {                     // ePub装载显示
    let params = URLSearchParams &&
       new URLSearchParams(document.location.search.substring(1))
    let url = params && params.get("url") && decodeURIComponent(params.get("url"))
    let currentSectionIndex = (params && params.get("loc")) ? params.get("loc") : undefined
    book = ePub(url || "/epubSets/作业报告书目.epub")
    rendition = book.renderTo("fileZone", {
      manager: "continuous", flow: "scrolled-doc", width: "auto", height: $("#fileZone").height()
    })
    rendition.display(currentSectionIndex)
  }
  dnmHeight(); epubLdShow()
  window.onresize = function () {
    book.destroy()
    dnmHeight()
    epubLdShow()
  }
  let setting = {                              // zTree控件操作
    data: {simpleData: {enable: true}},
    view: {fontCss: {color: 'white'}},
    callback: {onMouseDown: onMouseDown}
  }
  function drctShow(zNodes) {
    let zTreeObj = $.fn.zTree.init($("#treeZone"), setting, zNodes)
    zTreeObj.expandAll(true)
  }
  book.loaded.navigation.then(function(toc) {
    let nodes = [], k = [1, 1, 1, 1, 1]
	let nd = { pId: 0, id: (k[0]++), name: "电子作业报告选阅" }
	nodes.push(nd)
    toc.forEach(function(itmA) {
	  let lb = itmA.label
	  lb = lb.substring(1, lb.lastIndexOf('\n'))
	  lb = lb.trim()
	  if(lb!=="(无标题)") {
        nd = { pId: 1, id: k[0], name: lb, href: itmA.href }
        nodes.push(nd)
		let subItms2 = itmA.subitems, m = subItms2.length
		if(m>0) {
		  subItms2.forEach(function(itmB) {
	        lb = itmB.label
	        lb = lb.substring(1, lb.lastIndexOf('\n'))
	        lb = lb.trim()
			let x = (k[0]*10)+k[1]
            nd = { pId: k[0], id: x, name: lb, href: itmB.href }
            nodes.push(nd)
		    let subItms3 = itmB.subitems, m = subItms3.length
		    if(m>0) {
		      subItms3.forEach(function(itmC) {
	            lb = itmC.label
	            lb = lb.substring(1, lb.lastIndexOf('\n'))
	            lb = lb.trim()
			    let y = (x * 10) + k[2]
                nd = { pId: x, id: y, name: lb, href: itmC.href }
                nodes.push(nd)
		        let subItms4 = itmC.subitems, m = subItms4.length
		        if(m>0) {
		          subItms4.forEach(function(itmD) {
	                lb = itmD.label
	                lb = lb.substring(1, lb.lastIndexOf('\n'))
	                lb = lb.trim()
			        let z = (y * 10) + k[3]
                    nd = { pId: y, id: z, name: lb, href: itmD.href }
                    nodes.push(nd)
		            k[3]++
		          })
			    }
		        k[2]++
		      })
		    }
		    k[1]++
		  })
		}
    	k[0]++
      }
    })
    drctShow(nodes)
  })
  function onMouseDown(event, treeId, treeNode) { // 文件展开浏览
    if(treeNode==null) return
    rendition.display(treeNode.href)
    bookNm = treeNode.name
  }
  function sysShow() {                         // 跳转系统配置视窗
    lcl = "http://101.200.15.192:9605"
    let t = bookNm.substring(bookNm.indexOf(' ')+1)
    window.location.href = lcl + "/epubXpl?bookNm=" + t
  }
</script>
</html>
